﻿using System;
using System.Collections.Generic;
using System.Text;

namespace FlagEnum
{
    class Program
    {
        // Define an Enum without FlagsAttribute.
        enum SingleHue : short
        {
            Black = 0,
            Red = 1,
            Green = 2,
            Blue = 4
        };

        // Define an Enum with FlagsAttribute.
        [FlagsAttribute]
        enum MultiHue : short
        {
            Black = 0,
            Red = 1,
            Green = 2,
            Blue = 4
        };

        static void Main()
        {
            Console.WriteLine(
                "This example of the FlagsAttribute attribute \n" +
                "generates the following output.");
            Console.WriteLine(
                "\nAll possible combinations of values of an \n" +
                "Enum without FlagsAttribute:\n");

            // Display all possible combinations of values.
            for (int val = 0; val <= 8; val++)
            {
                Console.WriteLine("{0,3} - {1}", val, ((SingleHue)val).ToString());
            }

            Console.WriteLine(
                "\nAll possible combinations of values of an \n" +
                "Enum with FlagsAttribute:\n");

            // Display all possible combinations of values.
            // Also display an invalid value.
            for (int val = 0; val <= 8; val++)
            {
                Console.WriteLine("{0,3} - {1}", val, ((MultiHue)val).ToString());
            }

            Console.ReadLine();
        }

    }
}
